<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .user-list{
            width:1400px;
            display: flex;
            flex-wrap: wrap;
            margin:0 auto;
        }
        .user-card {
            width: 300px;
            height: 130px;
            margin:20px;
            display: flex;
            box-shadow: 0px 0px 10px #999;
        }

        .user-card .head {
            width: 120px;
            height: 130px;
        }

        .user-card .head img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .user-card .info {
            width: 150px;
            margin-left: 10px;
            margin-top: 10px;

            /* 字体的倍数 */
            line-height: 1.6;
        }

        .user-card .info .row {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            padding: 0px 10px;
        }

        .user-card .info .row span:first-child {
            display: inline-block;
            color: #999;
            width: 60px;

            /* 文字两端对齐 */
            text-align-last: justify;
        }

        .user-card .info .row:hover {
            background-color: #000;
            color: white;
            border-radius: 8px;

            /* 按照内容填充 */
            width: fit-content;
        }
    </style>
    <script src="mockjs/mock-min.js"></script>
</head>

<body>
    <div class="user-list">
        <!-- <div class="user-card">
            <div class="head">
                <img src="https://api.ixiaowai.cn/mcapi/mcapi.php" alt="">
            </div>
            <div class="info">
                <div class="row">
                    <span>编号:</span>
                    <span>1</span>
                </div>
                <div class="row">
                    <span>姓名:</span>
                    <span>张三</span>
                </div>
                <div class="row">
                    <span>性别:</span>
                    <span>男</span>
                </div>
                <div class="row">
                    <span>手机号:</span>
                    <span>13838384381</span>
                </div>
            </div>
        </div> -->
    </div>

    <script>
        function loadUserList() {
            let objs = {
                "users|9": [
                    {
                        no: "@id",
                        name: "@cname",
                        "sex|1": ["男", "女", "未知"],
                        tel: /^1[0-9]{10}$/,
                        img: "https://api.ixiaowai.cn/mcapi/mcapi.php?_=@datetime(T)"
                    }
                ]
            };
            return Mock.mock(objs);
        }
        let users = loadUserList().users;
        let str = "";
        users.forEach(function (item, index) {
            str += `
                    <div class="user-card">
                    <div class="head">
                        <img src="${item.img}" alt="">
                    </div>
                    <div class="info">
                        <div class="row">
                            <span>编号:</span>
                            <span>${item.no}</span>
                        </div>
                        <div class="row">
                            <span>姓名:</span>
                            <span>${item.name}</span>
                        </div>
                        <div class="row">
                            <span>性别:</span>
                            <span>${item.sex}</span>
                        </div>
                        <div class="row">
                            <span>手机号:</span>
                            <span>${item.tel}</span>
                        </div>
                    </div>
                </div>
            
            
            `;
        });

        let list=document.querySelector(".user-list");
        list.innerHTML=str;
    </script>

</body>

</html>